#include "logindialog.h"
#include "ui_logindialog.h"
#include <QMessageBox>

LoginDialog::LoginDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::LoginDialog)
{
    ui->setupUi(this);
    ui->pwdLineEdit->setEchoMode(QLineEdit::Password);//这里可以设置不显，也可以在属性中设置EchoMode
}

LoginDialog::~LoginDialog()
{
    delete ui;
}

void LoginDialog::on_loginBtn_clicked()
{
    //accept();//这个函数就是接收信号，退出，具体可以看help F1
    //[virtual slot] void QDialog::accept()
    //Hides the modal dialog and sets the result code to Accepted.
    //See also reject() and done().

    // 判断用户名和密码是否正确，
    // 如果错误则弹出警告对话框

    if(ui->usrLineEdit->text() == tr("name") &&
           ui->pwdLineEdit->text() == tr("123456"))
    {
       accept();
    } else {
       QMessageBox::warning(this, tr("警告！"),
                   tr("用户名或密码错误！"),
                   QMessageBox::Yes);
    }

}


